{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Concentric Transmon\n",
    "\n",
    "We'll be creating a 2D design and adding a single Concentric transmon QComponent.\n",
    "\n",
    "Simple Metal Transmon Concentric object. \n",
    "\n",
    "Metal transmon object consisting of a circle surrounding by a concentric \n",
    "ring. There are two Josephson Junction connecting the circle to the ring; \n",
    "one at the south end and one at the north end. There is a readout resonator. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# So, let us dive right in. For convenience, let's begin by enabling\n",
    "# automatic reloading of modules when they change.\n",
    "%load_ext autoreload\n",
    "%autoreload 2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import qiskit_metal as metal\n",
    "from qiskit_metal import designs, draw\n",
    "from qiskit_metal import MetalGUI, Dict, open_docs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Each time you create a new quantum circuit design, \n",
    "# you start by instantiating a QDesign class. \n",
    "\n",
    "# The design class `DesignPlanar` is best for 2D circuit designs.\n",
    "\n",
    "design = designs.DesignPlanar()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Launch Qiskit Metal GUI to interactively view, edit, and simulate QDesign: Metal GUI\n",
    "gui = MetalGUI(design)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### A Concentric Transmon\n",
    "You can create a ready-made concentric transmon qubit from the QComponent Library, `qiskit_metal.qlibrary.qubits`. \n",
    "`transmon_concentric.py` is the file containing our qubit so `transmon_concentric` is the module we import. \n",
    "The `TransmonConcentric` class is our concentic transmon qubit. Like all quantum components, `TransmonConcentric` inherits from `QComponent`. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from qiskit_metal.qlibrary.qubits.transmon_concentric import TransmonConcentric\n",
    "\n",
    "# Be aware of the default_options that can be overridden by user.\n",
    "TransmonConcentric.get_template_options(design)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# To force overwrite a QComponent with an existing name.  \n",
    "# This is useful when re-running cells in a notebook. \n",
    "design.overwrite_enabled = True"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Place the concentric transmon at (x,y) =(1,2)\n",
    "concentric_options = dict(\n",
    "    pos_x = '1um',\n",
    "    pos_y = '2um',\n",
    "    layer = '5', # default is 1, this is just for example.\n",
    "    pocket_w='1500um',  # transmon pocket width\n",
    "    pocket_h='900um',  # transmon pocket height\n",
    ")\n",
    "\n",
    "# Create a new Concentric Transmon object with name 'Q1' \n",
    "q1 = TransmonConcentric(design, 'qubit1', options=concentric_options)\n",
    "\n",
    "gui.rebuild()  # rebuild the design and plot \n",
    "gui.autoscale() #resize GUI to see QComponent\n",
    "gui.zoom_on_components(['qubit1']) #Can also gui.zoom_on_components([q1.name])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Let's see what the Q1 object looks like\n",
    "\n",
    "q1 #print Q1 information"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#Save screenshot as a .png formatted file.\n",
    "gui.screenshot()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "tags": [
     "nbsphinx-thumbnail"
    ]
   },
   "outputs": [],
   "source": [
    "# Screenshot the canvas only as a .png formatted file.\n",
    "gui.figure.savefig('shot.png')\n",
    "\n",
    "from IPython.display import Image, display\n",
    "_disp_ops = dict(width=500)\n",
    "display(Image('shot.png', **_disp_ops))\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Closing the Qiskit Metal GUI"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gui.main_window.close()"
   ]
  }
 ],
 "metadata": {
  "celltoolbar": "Tags",
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
